import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../pages/home.vue'
import Index from '../pages/index.vue'
import Product from '../pages/product.vue'
import Detail from '../pages/detail.vue'
import Order from '../pages/order.vue'
import OrderList from '../pages/list.vue'
import OrderConfirm from '../pages/confirm.vue'
import OrderPay from '../pages/pay.vue'
import AliPay from '../pages/aliPay.vue'
import Login from '../pages/login.vue'
import Cart from '../pages/cart.vue'
import Reg from '../pages/register.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/home',
    component: Home,
    children: [
      {
        path: '/index',
        component: Index
      },
      {
        path: '/product/:id',
        component: Product
      },
      {
        path: '/detail/:id',
        component: Detail
      }
    ]
  },
  {
    path: '/login',
    component: Login
  },
  {
    path: '/regiest',
    component: Reg
  },
  {
    path: '/order',
    component: Order,
    children: [
      {
        path: '/list',
        component: OrderList
      },
      {
        path: '/confirm',
        component: OrderConfirm
      },
      {
        path: '/pay',
        component: OrderPay
      },
      {
        path: '/alipay',
        component: AliPay
      }
    ]
  },
  {
    path: '/cart',
    component: Cart
  }
]

const router = new VueRouter({
  routes
})

export default router
